home *** CD-ROM | disk | FTP | other *** search
- ! "Intel 14.4EX Modem 9/30/92" Jim Gaynor
- ! Adapted from the Telebit WorldBlazer script, with parts from the
- ! SupraFAXModem v.32bis script and Microcom MacModem script
- ! "Telebit WorldBlazer Modem (V.32bis) 6/4/92" JFK
- ! Adapted from the Telebit T3000 script
- ! "Telebit T3000 Modem 11/11/91" JFK
- !
- @ORIGINATE
- @ANSWER
- !
- ! Talk to the modem at 19,200 bps. The Intel should auto-baud this
- ! unless the user has locked the port to a particular speed. If it
- ! is locked to a different speed, the user will need to change that.
- !
- serreset 19200, 0, 8, 1
- !
- ! The idea here is to get the modem into a known state, and then change only
- ! the registers that are necessary to support the connection. Most of the
- ! time AT&F will be sufficient, but some modems allow the user to change the
- ! F0 parameters. There isn't much that can be done to prevent this, but if
- ! the modem has any pre-configured configurations, and one of them sets
- ! hardware handshaking, use it.
- !
- ! Recall the factory configuration
- !
- settries 0
- matchclr
- @LABEL 1
- matchstr 1 4 "OK\13\10"
- write "AT&F\13"
- matchread 30
- inctries
- iftries 2 59
- ! Modem is not responding, reset and send a break
- DTRClear
- pause 5
- DTRSet
- SBreak
- jump 1
- !
- ! The script was able to get the modem into a default factory state. Now
- ! set the basic hardware type configuration such as command echo, hardware
- ! handshaking, and DTR control. If the &F command had not set up handshaking
- ! this is where it would be done. It's not desirable to create one long
- ! command string with everything on it because some modems cannot handle a
- ! long command string, and long strings are harder to debug. It's easy
- ! to enter an incorrect S-register value. For the most part, the following
- ! commands are probably common across a lot of modems, but always look up the
- ! commands in the modem manual.
- !
- ! Next, Set up the configuration: drop connection after losing DTR
- ! Turn off auto answer and command echo.
- !
- ! S0=0 - Don't answer calls
- ! E0 - Turn command echo off
- !
- @LABEL 4
- matchclr
- pause 5
- matchstr 1 5 "OK\13\10"
- write "ATS0=0E0\13"
- matchread 30
- jump 59
- !
- ! Now that the modem hardware & flow control parameters are set, make sure any
- ! protocol negotiation is disabled, and issue any modem specific features
- ! here. Make sure that MNP4/V.42, and MNP5-10/V.42bis negotiations are
- ! disabled. By the way, some V.32/V.32bis modems have an option to disable
- ! Trellis error control, which is part of the physical layer modulation.
- ! This is not the same as MNP/V.42, and you do not want to disable it!
- !
- ! Make sure that the modem is configured so it does NOT require error control
- ! to complete a link. ARA 1.0 does all error correction/data compression in
- ! software. All ARA wants is the fastest raw data pipe it can get. If the
- ! script spends time trying to negotiate some error control, the modems and/or
- ! Remote Access may time out.
- !
- ! It is important that the modem is configured so that it returns
- ! the connected speed, NOT the DTE speed. The script need to know what the
- ! real line speed is in order to set ARA's internal timers. Some
- ! modems don't have the option to display the line speed. In that case the
- ! performance of the connection may not be optimal.
- !
- ! Next, disable MNP and error control, set the delay before disconnect,
- ! and extended result codes (CTS/RTS flow control and internal DTE<->DCE
- ! buffering was set when &F9 was issued , so it is not necessary to do it
- ! again).
- !
- ! \N0 - "Normal" mode for communications (no LAPM or MNP)
- ! &D3 - DTR on/off resets modem
- !
- @LABEL 5
- pause 5
- matchstr 1 6 "OK\13\10"
- write "AT\\N0&D3\13"
- matchread 30
- jump 59
- !
- ! The modem should now be properly configured. Now check to see if the user
- ! has turned off the modem speaker. If they have, send an additional command
- ! to turn it off.
- !
- ! If speaker on flag is true, jump to label 8. Otherwise turn off the speaker.
- !
- @LABEL 6
- ifstr 2 8 "1"
- pause 5
- matchstr 1 8 "OK\13\10"
- write "ATM0\13"
- matchread 30
- jump 59
- !
- ! The modem is ready so enable answering, or originate a call.
- !
- @LABEL 8
- pause 5
- ifANSWER 30
- note "Dialing ^1" 3
- write "ATDT^1\13"
- !
- ! Be aware that different modems will have different format strings
- ! to return connection results. You need to understand the different possible
- ! strings and set this area (and then answer area at label 31) to the
- ! appropriate value. Also, remember that the modem was configured to return
- ! the connect speed if possible.
- !
- ! It's also useful if the modem can return busy, no dialtone, etc. since the script will
- ! be able to exit quicker and let the user know what is going on.
- !
- ! Also note that the script waits at the bottom of label 9 for a 70 seconds,
- ! rather then looping around. Why? Well, if the script re-issues the dial
- ! command too soon, that would cause the modem to hang up. At this point the
- ! script should wait a reasonable amount of time for one of these strings to
- ! return from the modem and take the appropriate action.
- !
- @LABEL 9
- matchstr 1 11 "CONNECT 1200\13\10"
- matchstr 2 12 "CONNECT 2400\13\10"
- matchstr 3 13 "CONNECT 4800\13\10"
- matchstr 4 19 "CONNECT 7200\13\10"
- matchstr 5 14 "CONNECT 9600\13\10"
- matchstr 6 20 "CONNECT 12000\13\10"
- matchstr 7 18 "CONNECT 14400\13\10"
- matchstr 8 50 "NO CARRIER\13\10"
- matchstr 9 50 "ERROR\13\10"
- matchstr 10 52 "NO DIALTONE\13\10"
- matchstr 11 53 "BUSY\13\10"
- matchstr 12 54 "NO ANSWER\13\10"
- matchread 700
- jump 59
- !
- ! All that is done for different connect speeds is to issue a
- ! "CommunicatingAt" command. Remember, the interface speed is locked
- ! to 19,200 bps so the script doesn't want to reset the serial speed after it
- ! connects.
- !
- ! CommunicatingAt tells ARA what the actual line speed is so that it
- ! can set it's timers appropriately. I guess performance would be
- ! sub-optimal if this is not set...
- !
- @LABEL 11
- note "Communicating at 1200 bps." 2
- CommunicatingAt 1200
- jump 15
- !
- @LABEL 12
- note "Communicating at 2400 bps." 2
- CommunicatingAt 2400
- jump 15
- !
- @LABEL 13
- note "Communicating at 4800 bps." 2
- CommunicatingAt 4800
- jump 15
- !
- @LABEL 19
- note "Communicating at 7200 bps." 2
- CommunicatingAt 7200
- jump 15
- !
- @LABEL 14
- note "Communicating at 9600 bps." 2
- CommunicatingAt 9600
- jump 15
- !
- @LABEL 20
- note "Communicating at 12000 bps." 2
- CommunicatingAt 12000
- jump 15
- !
- @LABEL 18
- note "Communicating at 14400 bps." 2
- CommunicatingAt 14400
- jump 15
- !
- ! Set CTS handshaking ON in the serial port (that's the 1 in the HSReset
- ! command below )
- !
- ! The modems have connected, so enable hardware handshaking on the serial
- ! port. If the script is answering a telephone call, just exit right away and
- ! starting communicating. If the script is dialing out, give the other end
- ! some time (3 seconds in this example) to get ready to talk to this modem.
- ! Exit 0 tells Remote Access that the script was successful in attempting a
- ! connection.
- !
- @LABEL 15
- HSReset 0 1 0 0 0 0
- ifANSWER 16
- pause 30
- @LABEL 16
- exit 0
- !
- ! Notice that the @ANSWER label is actually a comment here, and that
- ! @ORIGINATE and @ANSWER start at the same place. What's the point of having
- ! separate entry points if they are not used? Well, in the case of modems,
- ! when they dial out or wait for a call, the setup is usually the same. One
- ! reason for separate entry points is when the script is not directly talking
- ! to a modem, but maybe to a PBX or terminal server. It may be necessary to
- ! have completely different configuration for answering and originating
- ! connections.
- !
- ! @ANSWER
- ! Set up the modem to answer the telephone.
- !
- @LABEL 30
- write "ATS0=1\13"
- matchstr 1 31 "OK\13\10"
- matchread 30
- jump 59
- !
- ! What is userhook 1 doing in label 32? Here's the idea: Either this script
- ! controls a server that is waiting to answer the telephone, or it's waiting
- ! for a callback to a connection that was initiated. AppleTalk Remote Access
- ! does a "passive" listen on the serial port (via the Serial Port Arbitrator)
- ! so that other communications applications can use the serial port when ARA
- ! is not using it. When a call comes in for a server or callback, there
- ! will be about 5-14 seconds while the modems negotiate the connection.
- ! What would happen if a communications application on this Macintosh
- ! wanted to use the serial port during that time? Both connections
- ! would fail. The userhook 1 command tells ARA to mark the serial port in
- ! use. When that happens, applications that want to use the serial port will
- ! be told it's busy, and the incoming connection can complete. With that in
- ! mind, the strategy below is: When the modem receives a ring, jump to label
- ! 32, issue the userhook 1 command, then jump back up to label 31, wait for
- ! the connect result code and continue processing the script.
- !
- @LABEL 31
- matchstr 1 32 "RING\13\10"
- matchstr 2 11 "CONNECT 1200\13\10"
- matchstr 3 12 "CONNECT 2400\13\10"
- matchstr 4 13 "CONNECT 4800\13\10"
- matchstr 5 19 "CONNECT 7200\13\10"
- matchstr 6 14 "CONNECT 9600\13\10"
- matchstr 7 20 "CONNECT 12000\13\10"
- matchstr 8 18 "CONNECT 14400\13\10"
- matchstr 9 50 "NO CARRIER\13\10"
- matchstr 10 50 "ERROR\13\10"
- matchstr 11 52 "NO DIALTONE\13\10"
- matchstr 12 53 "BUSY\13\10"
- matchstr 13 54 "NO ANSWER\13\10"
- matchread 700
- jump 31
- !
- @LABEL 32
- userhook 1
- note "Answering phone..." 2
- jump 31
- !
- ! These are some common error messages when the line is busy, no dialtone,
- ! etc. They are documented in the Scripting Language Guide. When the script
- ! exits with a code other than zero, Remote Access knows that the connection
- ! failed, and will inform the user with a dialog.
- !
- ! 50: error messages
- !
- @LABEL 50
- exit -6021
- !
- @LABEL 52
- exit -6020
- !
- @LABEL 53
- exit -6022
- !
- @LABEL 54
- exit -6023
- !
- @LABEL 59
- exit -6019
- !
- ! Hang up the modem
- !
- @HANGUP
- @LABEL 60
- settries 0
- @LABEL 61
- write "ATH\13"
- matchclr
- matchstr 1 63 "OK\13\10"
- matchstr 2 63 "NO CARRIER\13\10"
- matchstr 3 63 "ERROR\13\10"
- matchread 30
- inctries
- iftries 3 63
- ! no response, try escape sequence
- write "+++"
- matchclr
- matchstr 1 62 "OK\13\10"
- matchread 20
- !
- ! No response from modem, toggle DTR
- !
- DTRClear
- pause 5
- DTRSet
- jump 61
- !
- @LABEL 62
- pause 5
- write "ATH\13"
- matchstr 1 63 "OK\13\10"
- matchstr 2 63 "NO CARRIER\13\10"
- matchstr 3 63 "ERROR\13\10"
- matchread 70
- jump 61
- !
- ! Recall factory settings
- !
- @LABEL 63
- pause 5
- matchclr
- matchstr 1 64 "OK\13\10"
- write "AT&F\13"
- matchread 30
- !
- ! Turn off auto answer
- !
- @LABEL 64
- write "ATS0=0\13"
- matchstr 1 65 "OK\13\10"
- matchread 30
- !
- ! Add delay to make sure other side of connection hangs up for call back.
- !
- @LABEL 65
- exit 0
-